package com.jml.netty.version5;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;


//
public class ServerHandler  extends ChannelHandlerAdapter {
	/**
	 * 当通道被调用,执行该方法
	 */
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		// 接收数据
		String value = (String) msg;
		System.out.println("Server msg:" + value);
		// 回复给客户端 “您好!”
		String res = "好的..._mayi";
		ctx.writeAndFlush(Unpooled.copiedBuffer(res.getBytes()));
	}


}
